<html>
<body>
<h2>Hello World!</h2>
<button type="button" id="a1">点这</button>
<p id="h1"></p>
</body>
<script type="text/javascript">
window.onload=function () {
    const a = document.getElementById("a1");
    a.onclick=function () {
        const xmlHttp=createXMLHttpRequest();
        xmlHttp.open("GET","url地址",true);
        xmlHttp.send(null);//GET请求没有请求体，也要给出null
        xmlHttp.onreadystatechange=function () {
            if(xmlHttp.readyState==4&&xmlHttp.status==200){
                //把获得的返回值赋给对象
            }
        };
    }
}
function createXMLHttpRequest(){
    try{
        return new XMLHttpRequest();
    }catch (e) {
        try{
            return new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e) {
            try{
                return new ActiveXObject("Microsoft.XMLHTTP");
            }catch (e) {
                alert("你用的是什么浏览器?");
                throw e;
            }
        }
    }
}
</script>
</html>
